package com.aba.bms.system;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public class SystemConfigDao {
    // 添加或更新配置
    public boolean saveOrUpdateConfig(String configKey, String configValue) throws SQLException {
        String sql = "INSERT INTO system_config (config_key, config_value) VALUES (?, ?) " +
                     "ON DUPLICATE KEY UPDATE config_value = ?";
//        try (Connection conn = DBUtil.getConnection();
//             PreparedStatement stmt = conn.prepareStatement(sql)) {
//            stmt.setString(1, configKey);
//            stmt.setString(2, configValue);
//            stmt.setString(3, configValue);
//            return stmt.executeUpdate() > 0;
//        }
        return true;
    }
 
    // 获取配置值
    public String getConfigValue(String configKey) throws SQLException {
        String sql = "SELECT config_value FROM system_config WHERE config_key = ?";
//        try (Connection conn = DBUtil.getConnection();
//             PreparedStatement stmt = conn.prepareStatement(sql)) {
//            stmt.setString(1, configKey);
//            ResultSet rs = stmt.executeQuery();
//            if (rs.next()) {
//                return rs.getString("config_value");
//            }
//            return null;
//        }
        return "";
    }

	public String getConfigKey() {
		// TODO Auto-generated method stub
		return null;
	}

	public String getDescription() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<SystemConfigDao> getAllConfigs() {
		// TODO Auto-generated method stub
		return null;
	}
}